package com.example.demo.vo

import com.example.demo.dao.TProductDao
import com.example.demo.dao.TProductTypeDao
import io.swagger.annotations.ApiModelProperty
import me.liuwj.ktorm.dsl.QueryRowSet

class ProductInfoVo {

    @ApiModelProperty(value = "id")
    var id: Int? = null

    @ApiModelProperty(value = "商品名称")
    var title: String? = null

    @ApiModelProperty(value = "图片url")
    var url: String? = null

    @ApiModelProperty(value = "价格")
    var price: Double? = null

    @ApiModelProperty(value = "销量")
    var sales: Int? = null

    @ApiModelProperty(value = "商品简介")
    var introduction: String? = null

    @ApiModelProperty(value = "规格")
    var specification: String? = null

    @ApiModelProperty(value = "商品id")
    var productTypeId: Int? = null

    @ApiModelProperty("商品类型名称")
    var productTypeTitle: String? = null


    fun getVo(queue: QueryRowSet): ProductInfoVo {
        queue.let {
            val productInfoVo = ProductInfoVo()
            productInfoVo.id = it[TProductDao.id]
            productInfoVo.url = it[TProductDao.url]
            productInfoVo.title = it[TProductDao.title]
            productInfoVo.specification = it[TProductDao.specification]
            productInfoVo.sales = it[TProductDao.sales]
            productInfoVo.price = it[TProductDao.price]
            productInfoVo.introduction = it[TProductDao.introduction]
            productInfoVo.productTypeId = it[TProductDao.productTypeId]
            productInfoVo.productTypeTitle = it[TProductTypeDao.name]
            return productInfoVo
        }
    }

}